package design.Memento;

/**
 * Created by looper on 2017/8/24.
 */
public class MementoTest {
  public static void main(String[] args) {
    Originator originator = new Originator();

    originator.setMissionNumber(99);
    System.out.println("现在正在过游戏的99关");

    Caretaker caretaker = new Caretaker();
    caretaker.setMemento(originator.createMemento());
    System.out.println("成功过关,开始存档");

    originator.setMissionNumber(100);
    System.out.println("现在正在过游戏的100关");

    System.out.println("很遗憾闯关失败,启动备忘录模式,回到最近通过的那一关");
    originator.restoreMemento(caretaker.getMemento());
    System.out.println("现在关数: "+originator.getMissionNumber());
  }
}
